/**  
 * @Title: UserServiceImpl.java  
 * @Package com.blog4java.example.service.impl  
 * @Description: TODO(用一句话描述该文件做什么)  
 * @author suyuhao  
 * @date 2025-06-11 12:11:09   
 */
package com.blog4java.example.service.impl;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.blog4java.example.entity.OperateLog;
import com.blog4java.example.entity.User;
import com.blog4java.example.mapper.OperateLogMapper;
import com.blog4java.example.mapper.UserMapper;
import com.blog4java.example.service.UserService;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;
    
    @Resource
    private OperateLogMapper operateLogMapper;

    @Override
    public boolean userRegister(User user) {
        String createTime = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
                .format(LocalDateTime.now());
        user.setCreateTime(createTime);
        if(userMapper.insert(user)>0) {
        	OperateLog log = new OperateLog();
        	log.setCreateTime(createTime);
        	log.setUserId(user.getId());
        	log.setContent("注册成功");
        	operateLogMapper.insert(log);
            return true;
        }        
        return false;
    }

    @Override
    public List<User> getAllUserInfo() {
        return userMapper.getAllUserInfo();
    }
}
